package com.umeng.analytics;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.umeng.common.b.g;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONObject;

public class d
{
  private ArrayList<JSONObject> a = new ArrayList();
  private ArrayList<JSONObject> b = new ArrayList();
  private HashMap<String, i> c = new HashMap();
  private HashMap<String, Map<String, String>> d = new HashMap();
  private int e = 10;

  // ERROR //
  private JSONObject a(JSONObject paramJSONObject, String paramString)
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_1
    //   3: ifnonnull +11 -> 14
    //   6: new 40	org/json/JSONObject
    //   9: dup
    //   10: invokespecial 41	org/json/JSONObject:<init>	()V
    //   13: astore_1
    //   14: aload_0
    //   15: getfield 24	com/umeng/analytics/d:a	Ljava/util/ArrayList;
    //   18: invokevirtual 45	java/util/ArrayList:size	()I
    //   21: istore 4
    //   23: iload 4
    //   25: ifle +60 -> 85
    //   28: aload_1
    //   29: ldc 47
    //   31: invokevirtual 51	org/json/JSONObject:isNull	(Ljava/lang/String;)Z
    //   34: ifeq +121 -> 155
    //   37: new 53	org/json/JSONArray
    //   40: dup
    //   41: invokespecial 54	org/json/JSONArray:<init>	()V
    //   44: astore 20
    //   46: aload_1
    //   47: ldc 47
    //   49: aload 20
    //   51: invokevirtual 58	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   54: pop
    //   55: aload 20
    //   57: astore 22
    //   59: aload_0
    //   60: getfield 24	com/umeng/analytics/d:a	Ljava/util/ArrayList;
    //   63: invokevirtual 62	java/util/ArrayList:iterator	()Ljava/util/Iterator;
    //   66: astore 23
    //   68: aload 23
    //   70: invokeinterface 68 1 0
    //   75: ifne +91 -> 166
    //   78: aload_0
    //   79: getfield 24	com/umeng/analytics/d:a	Ljava/util/ArrayList;
    //   82: invokevirtual 71	java/util/ArrayList:clear	()V
    //   85: aload_0
    //   86: getfield 26	com/umeng/analytics/d:b	Ljava/util/ArrayList;
    //   89: invokevirtual 45	java/util/ArrayList:size	()I
    //   92: istore 5
    //   94: iload 5
    //   96: ifle +55 -> 151
    //   99: aload_1
    //   100: ldc 73
    //   102: invokevirtual 51	org/json/JSONObject:isNull	(Ljava/lang/String;)Z
    //   105: ifeq +108 -> 213
    //   108: new 53	org/json/JSONArray
    //   111: dup
    //   112: invokespecial 54	org/json/JSONArray:<init>	()V
    //   115: astore 7
    //   117: new 40	org/json/JSONObject
    //   120: dup
    //   121: invokespecial 41	org/json/JSONObject:<init>	()V
    //   124: astore 8
    //   126: aload_0
    //   127: aload 8
    //   129: aload_2
    //   130: invokespecial 76	com/umeng/analytics/d:b	(Lorg/json/JSONObject;Ljava/lang/String;)Z
    //   133: pop
    //   134: aload 7
    //   136: aload 8
    //   138: invokevirtual 79	org/json/JSONArray:put	(Ljava/lang/Object;)Lorg/json/JSONArray;
    //   141: pop
    //   142: aload_1
    //   143: ldc 73
    //   145: aload 7
    //   147: invokevirtual 58	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   150: pop
    //   151: aload_0
    //   152: monitorexit
    //   153: aload_1
    //   154: areturn
    //   155: aload_1
    //   156: ldc 47
    //   158: invokevirtual 83	org/json/JSONObject:getJSONArray	(Ljava/lang/String;)Lorg/json/JSONArray;
    //   161: astore 22
    //   163: goto -104 -> 59
    //   166: aload 23
    //   168: invokeinterface 87 1 0
    //   173: checkcast 40	org/json/JSONObject
    //   176: astore 24
    //   178: aload 24
    //   180: ldc 89
    //   182: aload_2
    //   183: invokevirtual 58	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   186: pop
    //   187: aload 22
    //   189: aload 24
    //   191: invokevirtual 79	org/json/JSONArray:put	(Ljava/lang/Object;)Lorg/json/JSONArray;
    //   194: pop
    //   195: goto -127 -> 68
    //   198: astore 19
    //   200: aload 19
    //   202: invokevirtual 92	java/lang/Exception:printStackTrace	()V
    //   205: goto -120 -> 85
    //   208: astore_3
    //   209: aload_0
    //   210: monitorexit
    //   211: aload_3
    //   212: athrow
    //   213: aload_1
    //   214: ldc 73
    //   216: invokevirtual 83	org/json/JSONObject:getJSONArray	(Ljava/lang/String;)Lorg/json/JSONArray;
    //   219: astore 12
    //   221: iconst_m1
    //   222: aload 12
    //   224: invokevirtual 95	org/json/JSONArray:length	()I
    //   227: iadd
    //   228: istore 13
    //   230: goto +77 -> 307
    //   233: iload 14
    //   235: ifne -84 -> 151
    //   238: new 40	org/json/JSONObject
    //   241: dup
    //   242: invokespecial 41	org/json/JSONObject:<init>	()V
    //   245: astore 15
    //   247: aload_0
    //   248: aload 15
    //   250: aload_2
    //   251: invokespecial 76	com/umeng/analytics/d:b	(Lorg/json/JSONObject;Ljava/lang/String;)Z
    //   254: pop
    //   255: aload 12
    //   257: aload 15
    //   259: invokevirtual 79	org/json/JSONArray:put	(Ljava/lang/Object;)Lorg/json/JSONArray;
    //   262: pop
    //   263: goto -112 -> 151
    //   266: astore 6
    //   268: aload 6
    //   270: invokevirtual 92	java/lang/Exception:printStackTrace	()V
    //   273: goto -122 -> 151
    //   276: aload_0
    //   277: aload 12
    //   279: iload 13
    //   281: invokevirtual 99	org/json/JSONArray:get	(I)Ljava/lang/Object;
    //   284: checkcast 40	org/json/JSONObject
    //   287: aload_2
    //   288: invokespecial 76	com/umeng/analytics/d:b	(Lorg/json/JSONObject;Ljava/lang/String;)Z
    //   291: istore 18
    //   293: iload 18
    //   295: ifeq +9 -> 304
    //   298: iconst_1
    //   299: istore 14
    //   301: goto -68 -> 233
    //   304: iinc 13 255
    //   307: iload 13
    //   309: ifge -33 -> 276
    //   312: iconst_0
    //   313: istore 14
    //   315: goto -82 -> 233
    //
    // Exception table:
    //   from	to	target	type
    //   28	55	198	java/lang/Exception
    //   59	68	198	java/lang/Exception
    //   68	85	198	java/lang/Exception
    //   155	163	198	java/lang/Exception
    //   166	195	198	java/lang/Exception
    //   6	14	208	finally
    //   14	23	208	finally
    //   28	55	208	finally
    //   59	68	208	finally
    //   68	85	208	finally
    //   85	94	208	finally
    //   99	151	208	finally
    //   155	163	208	finally
    //   166	195	208	finally
    //   200	205	208	finally
    //   213	230	208	finally
    //   238	263	208	finally
    //   268	273	208	finally
    //   276	293	208	finally
    //   99	151	266	java/lang/Exception
    //   213	230	266	java/lang/Exception
    //   238	263	266	java/lang/Exception
    //   276	293	266	java/lang/Exception
  }

  private boolean b(JSONObject paramJSONObject, String paramString)
    throws Exception
  {
    JSONArray localJSONArray;
    int i;
    Iterator localIterator;
    if (paramJSONObject.has(paramString))
    {
      localJSONArray = paramJSONObject.getJSONArray(paramString);
      i = 1;
      localIterator = this.b.iterator();
    }
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        this.b.clear();
        paramJSONObject.put(paramString, localJSONArray);
        return i;
        localJSONArray = new JSONArray();
        i = 0;
      }
      localJSONArray.put((JSONObject)localIterator.next());
    }
  }

  public int a()
  {
    return (this.a.size() + this.b.size());
  }

  public void a(int paramInt)
  {
    this.e = paramInt;
  }

  public void a(Context paramContext)
  {
    String str;
    if (a() <= 0);
    do
    {
      return;
      str = h.e(paramContext).getString("session_id", null);
    }
    while (str == null);
    h.a(paramContext, a(h.i(paramContext), str));
  }

  public void a(String paramString)
  {
    if (this.c.containsKey(paramString))
    {
      ((i)this.c.get(paramString)).a(Long.valueOf(System.currentTimeMillis()));
      return;
    }
    i locali = new i(paramString);
    locali.a(Long.valueOf(System.currentTimeMillis()));
    this.c.put(paramString, locali);
  }

  public void a(String paramString, Map<String, String> paramMap)
  {
    if (this.d.containsKey(paramString))
      return;
    this.d.put(paramString, paramMap);
  }

  public boolean a(Context paramContext, String paramString1, String paramString2, long paramLong, int paramInt)
  {
    JSONObject localJSONObject;
    String str2;
    String str3;
    monitorenter;
    try
    {
      localJSONObject = new JSONObject();
      String str1 = g.a();
      label120: str3 = str1.split(" ")[1];
    }
    finally
    {
      try
      {
        localJSONObject.put("tag", paramString1);
        localJSONObject.put("date", str2);
        localJSONObject.put("time", str3);
        localJSONObject.put("acc", paramInt);
        if (!(TextUtils.isEmpty(paramString2)))
          localJSONObject.put("label", paramString2);
        if (paramLong > 0L)
          localJSONObject.put("du", paramLong);
        this.a.add(localJSONObject);
        boolean bool = b();
        monitorexit;
        return bool;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        break label120:
        localObject = finally;
        monitorexit;
        throw localObject;
      }
    }
  }

  public boolean a(Context paramContext, String paramString, Map<String, String> paramMap, long paramLong)
  {
    JSONObject localJSONObject;
    monitorenter;
    try
    {
      localJSONObject = new JSONObject();
    }
    finally
    {
      try
      {
        localJSONObject.put("id", paramString);
        localJSONObject.put("ts", System.currentTimeMillis());
        Iterator localIterator = paramMap.entrySet().iterator();
        int i = 0;
        if ((!(localIterator.hasNext())) || (i >= 10))
        {
          if (paramLong > 0L)
            localJSONObject.put("du", paramLong);
          this.b.add(localJSONObject);
          label91: boolean bool = b();
          monitorexit;
          return bool;
        }
        int j = i + 1;
        Map.Entry localEntry = (Map.Entry)localIterator.next();
        localJSONObject.put((String)localEntry.getKey(), (String)localEntry.getValue());
        i = j;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        break label91:
        localObject = finally;
        monitorexit;
        throw localObject;
      }
    }
  }

  public long b(String paramString)
  {
    if (this.c.containsKey(paramString))
      return ((i)this.c.get(paramString)).a().longValue();
    return -1L;
  }

  public boolean b()
  {
    return (this.a.size() + this.b.size() > this.e);
  }

  public Map<String, String> c(String paramString)
  {
    if ((this.c.containsKey(paramString)) && (((i)this.c.get(paramString)).b() > 0))
      return ((Map)this.d.get(paramString));
    return ((Map)this.d.remove(paramString));
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     com.umeng.analytics.d
 * JD-Core Version:    0.5.2
 */